package com.team.teamuserservice.controller;

import com.team.teamuserservice.service.UserCancelService;
import com.team.teamuserservice.uitls.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/rescue/cancel")
@RequiredArgsConstructor
public class UserCancelController {

    private final UserCancelService userCancelService;

    // 用户取消救援
    @GetMapping
    public Result cancelRescue(@RequestParam("userId") Long userId, @RequestParam("merchantId") Long merchantId) throws IOException {
        Boolean success = userCancelService.cancelRescue(userId, merchantId);

        if (!success){
            return Result.error("已经有商家取消了 , 你不用管了");
        }
        return Result.success();

    }



}
